﻿Imports Tom0014
Imports Tom0014TableAdapters
Partial Class pruebas_DataTable_y_TableAdapter
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim catalogo As New catalogo_generalDataTable
        Dim AdapCatalogo As New catalogo_generalTableAdapter
        Dim catRow1, catRow2 As catalogo_generalRow

        catalogo = AdapCatalogo.GetCatalogoByTipo("RL")

        catRow1 = catalogo.Newcatalogo_generalRow()
        catRow1.cattip = "RL"
        catRow1.catcve = "TLR"
        catRow1.catnom = "PRUEBA"
        catRow2 = catalogo.Newcatalogo_generalRow()
        catRow2.cattip = "RL"
        catRow2.catcve = "TL"
        catRow2.catnom = "PRUEBA 3"
        catalogo.Addcatalogo_generalRow(catRow1)
        catalogo.Addcatalogo_generalRow(catRow2)
        catalogo.Addcatalogo_generalRow("RL", "TOM", "RODRIGO")
        catalogo.Addcatalogo_generalRow("RL", "OHL", "OSCAR")
        catalogo.Addcatalogo_generalRow("RL", "APC", "ANTONIO")
        GridView1.DataSource = catalogo
        GridView1.DataBind()

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim catalogo As New catalogo_generalDataTable
        Dim adapCatalogo As New catalogo_generalTableAdapter

        'Response.Write(GridView1.Rows(0).Cells(2).Text)
        Dim i As Integer = 0
        For Each row In GridView1.Rows
            Dim cattip, catcve, catnom As String
            cattip = row.Cells(0).Text()
            catcve = row.Cells(1).Text()
            catnom = row.Cells(2).Text()
            ' Dim catrow As catalogo_generalRow
            catalogo.Addcatalogo_generalRow(cattip, catcve, catnom)
            ' Response.Write(row.Cells(2).Text())
            ' Response.Write(row.ToString)
        Next

        'catalogo.Count
        ' catalogo = GridView1 .
        adapCatalogo.Update(catalogo)



    End Sub
End Class
